#ifndef NETWORKPACKET_H
#define NETWORKPACKET_H

#include <QObject>
#include <QHash>
#include <QVariant>
#include <QDebug>

#include <qjson/parser.h>
#include <QVariantMap>

class NetworkPacket : public QObject
{
    Q_OBJECT
public:
    NetworkPacket(unsigned short packetType = 0, QByteArray rawData = 0);
    NetworkPacket* setParam(QString key, QVariant value);
    NetworkPacket* setBody(QByteArray data);
    QByteArray getBody();
    QByteArray rawData();
    void fromRawData(QByteArray rawData);
    unsigned int getPacketType();
    QVariantMap decodeJSON();
private:
    unsigned short packetType;
    QHash<QString,QVariant> *params = 0;
    QByteArray body;
};

#endif // NETWORKPACKET_H
